package com.wsoft.system.controller;

import com.wsoft.response.ResponseResult;
import com.wsoft.system.query.role.perm.RoleDataPermQuery;
import com.wsoft.system.service.ISysRolePermRelationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 *  前端控制器
 * @author zgk
 * @since 2024年09月23日 09:18:44
 */
@RestController
@Tag(name = "角色数据权限关系")
@RequestMapping("/sys/rolePermRelation")
public class SysRolePermRelationController {
    @Resource
    private ISysRolePermRelationService roleDataPermService;

    @Operation(summary = "根据角色id获取角色数据权限关系", description = "根据角色id获取角色数据权限关系")
    @GetMapping("/getPermListByRoleId")
    public ResponseResult getPermListByRoleId(@RequestParam("roleId") Long roleId) {
        return ResponseResult.success(roleDataPermService.getDataPermListByRoleId(roleId));
    }

    @Operation(summary = "配置角色数据权限关系", description = "配置角色数据权限关系")
    @PostMapping("/insertRelationByRoleId")
    public ResponseResult insertRelationByRoleId(@RequestBody RoleDataPermQuery query) {
        return ResponseResult.success(roleDataPermService.insertRelationByRoleId(query));
    }
}
